﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Net.Mail;

namespace chad.azure.diagnostics.data
{
    public class EmailProcessor
    {

        public static void SendEmail(String smtpServer, int port, 
            String subject, String body,
            String fromAddress, String[] toAddresses,
            String attachmentLocation)
        {
            

            using(SmtpClient smtp = new SmtpClient(smtpServer,port))
            {
                using(MailMessage msg = new MailMessage())
                {
                    msg.From = new MailAddress(fromAddress);
                    foreach (String to in toAddresses)
                    {
                        msg.To.Add(new MailAddress(to));
                    }
                    msg.Subject = subject;
                    msg.Body = body;
                    msg.Attachments.Add(new Attachment(attachmentLocation));

                    smtp.Send(msg);
                }
            }
        }

    }
}
